package org.fengling.readingplatform.achievement.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.fengling.readingplatform.achievement.mapper.AchievementMapper;
import org.fengling.readingplatform.achievement.service.AchievementService;
import org.fengling.readingplatform.model.entity.achievement.Achievement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AchievementServiceImpl implements AchievementService {

    @Autowired
    private AchievementMapper achievementMapper;

    // 成就列表的方法
    @Override
    public PageInfo<Achievement> findByPage(Integer pageNum, Integer pageSize) {
        // 设置分页参数
        PageHelper.startPage(pageNum, pageSize);
        // 根据条件查询所有数据
        List<Achievement> list = achievementMapper.findByPage();
        // 封装pageInfo对象
        PageInfo<Achievement> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
}
